package net.html;

import java.awt.EventQueue;
import java.awt.Frame;

import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.WindowConstants;

public class SimpleWebBrowser
{
	public static void main(String[] args)
	{
		String initialPage = "http://www.taobao.com";
		if(args.length>0)
		{
			initialPage = args[0];
		}
		
		JEditorPane jep = new JEditorPane();
		jep.setEditable(false);
		jep.addHyperlinkListener(new LinkFollower(jep));
		
		try
		{
			jep.setPage(initialPage);
		}
		catch (Exception e)
		{
		}
		JScrollPane scrollPane = new JScrollPane(jep);
		JFrame f = new JFrame("frame");
		f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		f.setContentPane(scrollPane);
		f.setSize(500, 500);
		EventQueue.invokeLater(new FrameShower(f));
	}
	private static class FrameShower implements Runnable{
		private final Frame frame;
		public FrameShower(Frame frame)
		{
			this.frame = frame;
		}
		@Override
		public void run()
		{
			frame.setVisible(true);
		}}
}
